<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
>

<html lang="en">
<head>
	<head th:include="header::header"></head>
	<title>普惠商城-个人中心-账户设置-账户安全-实名认证</title>
</head>
<body>
	
	<!-- 顶部导航条开始 -->
	<div  th:include="personal/personalhead::order-personalhead-nav"></div>
	<!-- 顶部导航条结束 -->
	<!-- 顶部搜索栏部分开始 -->
	<div  th:include="personal/personalsearch::order-personalsearch-nav"></div>
	<!--个人中心中间主体框架  -->
	<div class="centerbody personal_middle">
		<!-- 左侧通用导航栏 -->
		<div class="personal_middle_nav" th:include="commonfragment::order-left-menu-nav"></div>
		<div class="centerbody personal_middle_main">
			<div class="personal_middle_main_tit">
				<span>帐户设置</span>><span>帐户安全</span>><span>实名认证</span>
			</div>
			<!-- 订单tab标签 -->
			<div data-role="page">
        		<div data-role = "content-floud">
					<div class="publicBox">
						<div class="realName pad_20">
							<p class="realNameForm"><label>真实姓名：</label><input type="text" value="" placeholder="请输入您的真实姓名" id="realName"></p>
							<p class="realNameForm"><label>身份证号：</label><input type="text" value="" placeholder="请输入您的真实身份证号	" id="idNumber"></p>
							<p class="realNameBut"><button id = "authSubmit">认证</button></p>
						</div><!--LineConf-->
					</div><!--个人信息-->
				</div>
   			 </div>
			<!-- 全部订单 -->
			
		</div>
		<div style="clear:both;"></div>
	</div>
	
	<!-- 页面底部 -->
	<div th:include="footer::footer"></div>

</body>
<script type="text/javascript" th:src="@{/js/card.js}"></script>
<script th:inline="javascript">
$(function(){
	/*tab标签切换*/
    function tabs(tabTit,on,tabCon){
        $(tabCon).each(function(){
            $(this).children().eq(0).show();
        });
        $(tabTit).each(function(){
            $(this).children().eq(0).addClass(on);
        });
        $(tabTit).children().click(function(){
            $(this).addClass(on).siblings().removeClass(on);
            var index = $(tabTit).children().index(this);
            $(tabCon).children().eq(index).show().siblings().hide();
        });
    }
    tabs(".LineTitle","Line_on",".LineCon");
	$(".box1 input:checked").parent().parent().addClass("selected");
	$(".box1 input").change(function(){
        $(".box1 input:checked").parent().parent().addClass("selected").siblings().removeClass("selected");
    });
   		$('input.paybutton').eq(0).addClass('choose');
   		
   		$('input.paybutton').hover(function(){
   			$(this).addClass('choose');
   			$(this).siblings().removeClass('choose');
   		},function(){
   			$(this).removeClass('choose');
   		})
    	$('.cancel_small').click(function(){
			$('.shadow').css('display','none');
			$('.login_box_2').css('display','none');
		})
		
		$('.add_info').click(function(){
			$('.shadow').css('display','block');
			$('.login_box_2').css('display','block');
		})
		$('.shadow').css('height',$(window).height());
			$('.login_box_2').css('top',($(window).height()-$('.login_box_2').height())/2);
			$('.login_box_2').css('left',($(window).width()-$('.login_box_2').width())/2);
		$(window).resize(function(){
			$('.shadow').css('height',$(window).height());
			$('.login_box_2').css('top',($(window).height()-$('.login_box_2').height())/2);
			$('.login_box_2').css('left',($(window).width()-$('.login_box_2').width())/2);
		})
		 $("#hear li").click(function(){
    $(this).css({
         borderBottom: "2px solid red",
         height:"43px"
    }).siblings().css({
        borderBottom: "none",
        height:"45px"
    });
});                
                         
$("#hear li").click(function(){
        $(this).addClass("action").siblings().removeClass("action");
        var index = $(this).index();
        $("#contentop li").eq(index).css("display","block").siblings().css("display","none");
        });
})
// 绑定提交
$('#authSubmit').click(function(){
	if(relNameAuth.isNotNull("realName") && relNameAuth.isNotNull("idNumber") 
			&& relNameAuth.identityCodeValid($('#idNumber').val())){
		var realName = $('#realName').val();
		var idNumber = $('#idNumber').val();
		$.ajax({
			url:'/account/realNameAuth',
			type:"post",
			dataType:"json",
			data:{"name":realName,"idCode":idNumber},
			error:function(){
				layer.msg("系统繁忙，请稍后再试！");
			},
			success:function(data){
				if(data.code == "200"){
					layer.msg("认证成功");
					$("#authSubmit").hide();
				}else{
					layer.msg(data.message);
				}
			}
		})
	}
})

var tipsIndex;
$(function(){
	relNameAuth.bingClosetipsIndex();
});
// 实名认证相关函数
var relNameAuth = {
	isNotNull : function(id){
		var flag = true;
		var val = $('#'+id).val();
		if(val.trim().length < 1){
			tipsIndex = layer.tips("此处不能为空","#"+id,{tips: 2});
			flag = false;
		}
		return flag;
	},
	bingClosetipsIndex : function(){
		$('#realName').on("focus",function(){
			if(tipsIndex){
				layer.close(tipsIndex);
			}
		});
		$('#idNumber').on("focus",function(){
			if(tipsIndex){
				layer.close(tipsIndex);
			}
		});
	},
	//身份证号合法性验证 
	//支持15位和18位身份证号
	//支持地址编码、出生日期、校验位验证
	identityCodeValid : function(code){
		var pass = idCardNoUtil.checkIdCardNo(code);
		var tip = "";
		if(!pass){
			tip = "身份证号格式错误";
			tipsIndex = layer.tips(tip,"#idNumber",{tips: 2});
		}
	    return pass;
	}
}
</script>

</html>